#include "BlockQueue.hpp"
#include<ctime>
#include<unistd.h>
void *Consumer(void *args)
{
    BlockQueue<int> *bq=static_cast<BlockQueue<int> *>(args);
    while(true)
    {
        sleep(1);
        int date;
        bq->Pop(&date);
        //t()处理任务
        std::cout<<"get date:"<<date<<std::endl;
    }
    //return (void*)0;
}
void *Productor(void *args)
{
    BlockQueue<int> *bq=static_cast<BlockQueue<int> *>(args);   
    while(true)
    {
        int date=rand()%10+1;
        bq->Equeue(date);
        std::cout<<"put date:"<<date<<std::endl;
    }
    //return (void*)0;
}




int main()
{
    srand(time(nullptr));
    BlockQueue<int> *bq=new BlockQueue<int>();
    pthread_t c,p;
    pthread_create(&c,nullptr,Consumer,bq);
    pthread_create(&p,nullptr,Productor,bq);

    pthread_join(c,nullptr);
    pthread_join(p,nullptr);
}